package cn.iocoder.yudao.module.picturebook.dal.mysql.audioself;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.picturebook.dal.dataobject.audioself.AudioSelfDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.picturebook.controller.admin.audioself.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 绘本自己录音 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface AudioSelfMapper extends BaseMapperX<AudioSelfDO> {

    default PageResult<AudioSelfDO> selectPage(AudioSelfPageReqVO reqVO,Long userId) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AudioSelfDO>()
                .eqIfPresent(AudioSelfDO::getBookId, reqVO.getBookId())
                .eqIfPresent(AudioSelfDO::getCurrentPage, reqVO.getCurrentPage())
                .eqIfPresent(AudioSelfDO::getAudioIdUrl, reqVO.getAudioIdUrl())
                .eqIfPresent(AudioSelfDO::getCreator, userId)
                .betweenIfPresent(AudioSelfDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AudioSelfDO::getUpdateTime));
    }

    Integer isExist(@Param("userId") Long userId, @Param("bookId") Long bookId, @Param("currentPage") String currentPage);
}